<%@page import="cn.jhc.bean.HfmsgBean"%>
<%@page import="cn.jhc.bean.UserBean"%>
<%@page import="cn.jhc.bean.AllHfmsgBean"%>
<%@page import="java.util.ArrayList"%>
<%@page import="cn.jhc.dao.ConnectionFactory"%>
<%@page import="cn.jhc.dao.MsgDao"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" import="cn.jhc.bean.UserBean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="./css/taolunqu.css"></link>
<title>留言板</title>
</head>
<body>
<% 
int CurrentPage=1; //初始值,第一页
int intPageCount;	//全部的也数
if(request.getParameter("page")!=null) //判断传过来的数据
CurrentPage=Integer.parseInt(request.getParameter("page")); //装换为整形
if(CurrentPage<1) //使初始值不小于一，始终是第一页
CurrentPage=1; 
%>
	<div id="wrapper">
		<%
			String id = request.getParameter("id");
			int Id = Integer.parseInt(id);
			HfmsgBean m = new HfmsgBean();
			MsgDao dao = new MsgDao();
			dao.setCon(ConnectionFactory.getConnection());
			m = dao.getoneMessages(Id);
			request.setAttribute("title", m);
		%>
			<jsp:include page="./header.jsp"></jsp:include>
			<div id="name">昵称：${requestScope.title.displayname}</div>
			<div id="title">标题：${requestScope.title.title}</div>
			<div id="content">内容：${requestScope.title.content}</div>
		<%
			dao.setCon(ConnectionFactory.getConnection());
			ArrayList<AllHfmsgBean> h = new ArrayList<AllHfmsgBean>();
			h = dao.getHFMessages(Id,CurrentPage);
			request.setAttribute("liuyan", h);
		%>

		
		<%
		MsgDao dao2 = new MsgDao();
    	dao2.setCon(ConnectionFactory.getConnection());
    	intPageCount=dao2.getHfCount(Id);
    	if(CurrentPage>intPageCount) 
  			CurrentPage = intPageCount; 
		%>
			<c:forEach var="liuyan" items="${requestScope.liuyan}">
				<div id="newmessage">
				<div class="name">昵称：${liuyan.displayname}</div>
				<div class="newcontent">回复：${liuyan.content}</div>
				</div>
			</c:forEach>
		<div align="right">
			<a>第<%=CurrentPage%>页 共<%=intPageCount%>页</a>
			<a href="showmessages.jsp?page=<%=1%>&id=${requestScope.title.id}">首页</a>
			<%if(CurrentPage>1){%>
			<a href="showmessages.jsp?page=<%=CurrentPage-1%>&id=${requestScope.title.id}">上一页</a>
			<%}else{%>
			上一页
			<%}%>
			<%if(CurrentPage>=intPageCount){%>
			下一页
			<%}else{%>
			<a href ="showmessages.jsp?page=<%=CurrentPage+1%>&id=${requestScope.title.id}">下一页</a>
			<%}%>
			<a href="showmessages.jsp?page=<%=intPageCount%>&id=${requestScope.title.id}">末页</a>
		</div>
		<div id="submit">
			<form method="post"
				action="./addHfmessage.do?titleid=${requestScope.title.id}&getb=/showmessages.jsp&id=${requestScope.title.id}">
				<p>
					<label for="content">内容</label>
					<textarea rows="7" cols="60" name="content">内容不能为空</textarea>
				</p>
				<p>
					<input type="submit" value="提交"></input> <input type="reset" />
				</p>
		</form>
		</div>
	</div>
</body>
</html>




